<?php
require_once './function.php';

$json = do_post_request("http://localhost:9095/get4listen");
$list = json_decode($json, true);
?>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Cache-Control" content="no-transform">
    <title>CET4</title>
    <link rel="shortcut icon" href="/Public/img/favicon.ico"/>
    <link href="./Public/css/bootstrap.css" rel="stylesheet">
    <link href="./Public/css/main.css" rel="stylesheet" type="text/css" />
    <link href="./Public/css/index.css" rel="stylesheet" type="text/css" />
    <link href="./Public/css/detail.css" rel="stylesheet" type="text/css" />
    <link href="./Public/css/user.css" rel="stylesheet" type="text/css" />
    <link href="./Public/css/announcement.css" rel="stylesheet" type="text/css" />
    <link href="./Public/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
    <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script>
        var rootUrl = '';
    </script>
</head>
<body>


<div class="container">

     <header class="header">
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="row">
                <div class="hidden-xs hidden-sm col-md-3 col-lg-3">
                    <div class="navbar-header navbar-left">
                        <a class="navbar-brand-mc" href="/">
                            <img src="./Public/img/logo.png" alt="logo"/>
                        </a>
                    </div>
                </div>
                <div class="hidden-xs visible-sm-block col-sm-2">
                    <div class="navbar-header navbar-left">
                        <a class="navbar-brand-mc" href="/">
                            <img src="/Public/img/Brand-M.png" alt="logo"/>
                        </a>
                    </div>
                </div>
                <div class="visible-xs-block col-xs-2">
                    <div class="navbar-header navbar-left">
                        <a class="navbar-brand-mc" href="/">
                            <img src="/Public/img/Brand-S.png" alt="logo"/>
                        </a>
                    </div>
                </div>
                <div class="col-xs-8 col-sm-5 col-md-5 col-lg-5">
                     <!--<div class="navbar-search navbar-left">-->
                        <form class="navbar-form-mc" method="get" action="/course/search" role="search">
                            <div class="input-group input-group-nav">
                                <input type="text" class="form-control" id="input-search" name="key" placeholder="查找试卷...">
                                <span class="input-group-btn">
                                    <a role="button" href="search.html" style="background-image:url('/Public/img/icon-search.png');height:100%;" class="btn" aria-label="Left Align" onclick="$(this).closest('form').submit()">
                                    </a>
                                </span>
                            </div>
                        </form>
                    <!--</div>-->
                </div>
                <div id="list1">
                <div class="hidden-xs col-sm-5 col-md-4 col-lg-4">
                    <div id="navbar" class="navbar-collapse collapse">
                        <ul class="nav navbar-nav pull-right">
                            <li id="nav-index"><a href="/">首页</a></li>
                            <li id="nav-course"><a href="course.php">试卷</a></li>
                        
                            <li><a href="/">登录</a></li>
                                
                        </ul>
                    </div>
                </div>
                <div class="visible-xs-block col-xs-2">
                    <div class="nav nav-hamburger pull-right">
                        <a href="#ham" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span></a>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="/">首页</a></li>
                            <li><a href="/course">试卷</a></li>
                         
                            <li><a href="/">登录</a></li>
                                
                        </ul>
                    </div>

                </div>
                </div>
        <div id="list2" style="display: none">
           <div class="hidden-xs col-sm-5 col-md-4 col-lg-4">
                    <div id="navbar" class="navbar-collapse collapse">
                        <ul class="nav navbar-nav pull-right">
                            <li id="nav-index"><a href="/">首页</a></li>
                            <li id="nav-course"><a href="/course">课程</a></li>
                            <li id="nav-notice"><a href="/announcement">公告</a></li>
                                                            <li id="nav-user" class="dropdown">
                                    <a href="#user" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">个人 <span class="caret"></span></a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href="userhome.html">个人主页</a></li>
                                        <li><a href="/">资料设置</a></li>
                                        <li><a href="/user/logout" class="logout">退出登录</a></li>
                                    </ul>
                                </li>
                        </ul>
                    </div>
                </div>
                <div class="visible-xs-block col-xs-2">
                    <div class="nav nav-hamburger pull-right">
                        <a href="#ham" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span></a>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="/">首页</a></li>
                            <li><a href="/course">课程</a></li>
                            <li id="xs-nav-notice"><a href="/announcement">公告</a></li>
                                                            <li><a href="/user">个人主页</a></li>
                                <li><a href="/user/basic">资料设置</a></li>
                                <li><a href="/user/logout" class="logout">退出登录</a></li>
                        </ul>
                    </div>
                </div>
                </div>
            </div>
        </div>
    </nav>
</header>


    <div class="content">

        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
                <div class="section">
                    <h4>试卷列表</h4>
                    <?php
                            foreach($list as $item){
                                echo '<ul>
                                    <li><a href="exercise.php?id='.$item['id'].'">'.$item['listenName'].'</a></li>
                            </ul>
                            ';                                
                            }                            
                            ?>
                   
                </div>
            </div>
             <div class="hidden-xs hidden-sm col-md-4 col-lg-4">
                <div class="section section-courses">
                    <h4>试卷推荐</h4>
                    <a href="" target="_blank">2016年CET6真题<span></span></a>
                </div>
                <div class="section">
                    <h4>标签推荐</h4>
                    <a class="tag tag-info" href="CET4.php">CET4</a>
                    <a class="tag tag-info" href="CET6.php">CET6</a>
                    <a class="tag tag-info" href="professional.php">专业英语</a>
                    <a class="tag tag-info" href="IELTS.php">雅思</a>
                    <a class="tag tag-info" href="TOEFL.php">托福</a>
                </div>
            </div>
        </div>
    </div>

</div>


<!-- Modal Feedback End -->
<script src="./Public/js/footer.js" ></script>
<script src="./Public/js/header.js" ></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script>
    $('#nav-course').addClass('active');
</script>
<script>
    function onload(){
      var list1=document.getElementById("list1");
      var list2=document.getElementById("list2");
      $.get(
             "http://localhost:9095/getuserstatus",
     {
         
     },
     function(data)
     {
         if(data){
//             alert("yes");
             $('.log-or-sign').hide();
             list1.style.display="none";
            list2.style.display="block";
         }
         else{
//             alert("no");
         }
     }
                );
  }
  window.reload=onload();
    </script>

</body>
</html>